package site.teamo.biu.flink.web.configuration;

import cn.hutool.core.io.FileUtil;
import lombok.Getter;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;

import java.io.File;

/**
 * @author haocongshun
 * @date 2023/10/30 17:30:28
 */
@Configuration
public class BiuFlinkConfig {

    @Getter
    @Value("${biu-flink.workspace-path}")
    private String workspacePath;

    public String getFunctionPackagePath() {
        return createPathIfNotExist(workspacePath + File.separator + "function-package");
    }


    public String getTempPath() {
        return createPathIfNotExist(workspacePath + File.separator + "temp");
    }

    public String getToolLibPath() {
        return workspacePath + File.separator + "tool-lib";
    }

    public String getSdkLibPath() {
        return workspacePath + File.separator + "sdk-lib";
    }

    private String createPathIfNotExist(String path) {
        if (!FileUtil.exist(path)) {
            FileUtil.mkdir(path);
        }
        return path;
    }
}
